﻿using Mbl.ParameterizedTest;
using System;
using System.Collections.Generic;

namespace NParameterizedTestTests.ObjectBuilders
{
    public class TestCollectionBuilder
    {
        private Action _setup = () => { };
        private Func<int, int, int> _methodUnderTest = (a, b) => 0;
        private readonly List<TestCase<int, int, int>> _testCases = new List<TestCase<int, int, int>>();

        public TestCollection<int, int, int> Build()
        {
            var collection = new TestCollection<int, int, int>(_setup, _methodUnderTest);
            foreach(var testCase in _testCases)
            {
                collection.AddTestCase(testCase);
            }

            return collection;
        }

        public TestCollectionBuilder WithSetup(Action setup)
        {
            _setup = setup;
            return this;
        }

        internal TestCollectionBuilder WithTestCase()
        {
            var testCase = new TestCaseBuilder().Build();
            _testCases.Add(testCase);
            return this;
        }

        internal TestCollectionBuilder WithMethodUnderTest(Func<int, int, int> methodUnderTest)
        {
            _methodUnderTest = methodUnderTest;
            return this;
        }
    }
}
